package com.esm.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.esm.service.UserService;
import com.esm.serviceimpl.UserServiceImpl;
import com.esm.utils.PrintWriterUtil;

import net.sf.json.JSONArray;

/**
 * SelectEmployeesController
 * 查询全体员工控制者
 * @author 魏长均
 *
 */
public class SelectEmployeesController_wcj extends HttpServlet
{
	private static final long serialVersionUID = 1L;
	UserService uService = new UserServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
	{
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
	{
		//员工角色id号
		int rid = Integer.parseInt(req.getParameter("rid"));
		//获取页面页码的请求参数
		int page = Integer.parseInt(req.getParameter("page"));
		int pageSize = Integer.parseInt(req.getParameter("pageSize"));
		//根据分页请求获取员工查询结果集  
		JSONArray jao = uService.getAllEmployees(rid,page,pageSize);
		//回写数据
		PrintWriter pw = resp.getWriter();
		PrintWriterUtil.flushJaoAndClosePrintWriter(pw, jao);
	}
	
}
